package com.labo.erpcrm.dao;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.criterion.Restrictions;

import com.labo.erpcrm.bean.LigneCommande;

public class LigneCommandeDao extends GenericRepository<LigneCommande, Integer> {
	
	public LigneCommande GetById(Integer Id){
		Session s = HelperSessionFactory.getSession();
		Transaction trans = s.beginTransaction();
		Criteria criteria = s.createCriteria(LigneCommande.class).add(Restrictions.eq("id_ligne_commande", Id));
		LigneCommande ligneCommande = (LigneCommande) criteria.uniqueResult();
		trans.commit();
		return ligneCommande;
	}

	@SuppressWarnings("unchecked")
	public List<LigneCommande> GetAll(){
		Session s = HelperSessionFactory.getSession();
		Transaction trans = s.beginTransaction();
		Criteria criteria = s.createCriteria(LigneCommande.class);
		List<LigneCommande> lst = (List<LigneCommande>) criteria.list();
		trans.commit();
		return lst ;
	}

}
